<template>
    <view class="CardStyle">
        <view class="Item" v-for="(item,index) in cart_style_List" :key="index">
            <view>
                <view class="card_style_font">{{ item.name }}</view>
                <view class="ckeckbox" @click="()=>{changeBgImg(item)}">
                    <img v-if="item.state" src="/src/icon/dui.png" class="icon" alt="">
                </view>
            </view>
            <view class="imgView">
                <img :src="item.img" alt="">
            </view>
        </view>
    </view>
</template>
<script setup>
import {reactive} from 'vue'
import { useCounterStore } from '@/store/counter'
const counterStore = useCounterStore()
const cart_style_List = reactive([
    {
        name:"小牌模式",
        img:"/src/static/cardStyle/tu1.png",
        state:true
    },
    {
        name:"大牌模式",
        img:"/src/static/cardStyle/tu2.png",
        state:false
    }
])
const changeBgImg = (ItemVal) => {
    counterStore.changeBgImg(ItemVal.name)
  const idx = cart_style_List.findIndex(item => item.name === ItemVal.name);
  cart_style_List.forEach((item, i) => {
    if(i==idx){
        item.state = true
    }else{
        item.state = false
    }
  });
};
</script>
<style scoped>
.CardStyle{
    width:100%;
    height:94vh;
    margin-top: 6vh;
    padding: 2vw 5vw;
    box-sizing: border-box;
    background-color: #1c1526;
}
.card_style_font{
    color: #eee;
}
.Item{
    width:100%;
    padding:3vw;
    background-color:#51336c;
    box-sizing: border-box;
    margin-top: 3vh;
    position: relative;
}
.imgView{
    width: 100%;
    height: 10vh;
    background-color: #1c1526;
    margin-top: 3vw;
}
.imgView img{
    width: 100%;
    height: 10vh;
}
.icon-fanhui {
  font-size: 24px;
  color: white;
  padding: 5px;
}
.ckeckbox{
    position: absolute;
    width: 5vw;
    height: 5vw;
    right: 1vw;
    top:1vw;
    background-color: white;
    line-height: 5vw;
    text-align: center;
}
.icon-duihao{
    font-size: 5vw;
    color: #45c01a;
    font-weight: bold;
}
.icon{
    width: 5vw;
    height: 5vw;
}
</style>